﻿using System;
using System.IO;

public partial class _Default : System.Web.UI.Page 
{

    public String m_sxViewUserId
    {
        get
        {
            return ICPUser.ID;
        }
    }

    public String m_sxViewFristName
    {
        get
        {
            return ICPUser.Name.Substring(0, ICPUser.Name.LastIndexOf(" "));
        }
    }
    public String m_sxViewLastName
    {
        get
        {
            return ICPUser.Name.Substring(ICPUser.Name.LastIndexOf(" "), ICPUser.Name.Length - ICPUser.Name.LastIndexOf(" "));
        }
    }
    //public bool MenuPriviledge(String sxMenu)
    //{
    //    bool bShow = false;
    //    try
    //    {
    //        bShow = (Page as ICPGeneralPage).m_lsPrivilledges.Contains(sxMenu);
    //    }
    //    catch { }
    //    return bShow;
    //}
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }


    private bool IsCombinedJSOlder(string path)
    {
        var jsPath = Context.Server.MapPath(path);
        string[] files = Directory.GetFiles(jsPath);

        var combinedFileLastWrite = File.GetLastWriteTime(Server.MapPath("~/js/Combined.js"));

        return Array.Exists(files, file => (File.GetLastWriteTime(file) - combinedFileLastWrite).TotalSeconds > 1);
    }

    protected string GetAlerts()
    {
        if (!Request.IsLocal)
        {
            if (IsCombinedJSOlder("~/js/") || IsCombinedJSOlder("~/Tiles/"))
            {
                return "$('#CombinedScriptAlert').show();";
            }
            else
            {
                return string.Empty;
            }
        }
        else
        {
            return string.Empty;
        }
        
    }
}